﻿<%@ Page Title="Sms Mo Statistics" Language="C#" MasterPageFile="~/App_MasterPages/Aquarius.Master"
    AutoEventWireup="true" CodeBehind="SmsMoStatistics.aspx.cs" Inherits="PepsiCo.UI.SmsMoStatistics" %>

<%@ Register Src="UserControl/ucPaging.ascx" TagName="ucPaging" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CssContent" runat="server">
    <style type="text/css">
        a.subs
        {
            color: #696969;
            text-decoration: none;
        }
        a.subs:hover
        {
            text-decoration: underline;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ScriptContent" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {
            dialog();
            $("#<%=txtFromDate.ClientID%>").datepicker();
            $("#<%=txtToDate.ClientID%>").datepicker();
        });
        function GetMT(obj) {
            var mo_guid = $("input", obj).val();
            $.ajax({
                type: "POST",
                url: "WebService.asmx/GetMT",
                data: "{'mo_guid':" + JSON.stringify(mo_guid) + "}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    var tbody = $("#tbMT tbody");
                    tbody.find("tr").remove();
                    for (i = 0; i < data.d.length; i++) {
                        var html =
                            "<tr " + (i % 2 == 0 ? "" : "class='odd'") + ">" +
                            "   <td align='center'>" + (i + 1) + "</td>" +
                            "   <td>" + data.d[i].ShortCode + "</td>" +
                            "   <td>" + data.d[i].DestAddr + "</td>" +
                            "   <td>" + data.d[i].Message + "</td>" +
                            "   <td>" + ParseJsonDate(data.d[i].SentTime) + "</td>" +
                            "   <td>" + data.d[i].Status + "</td>"
                        "</tr>";
                        tbody.append(html);
                    }
                }
            });
        }
        function dialog() {
            $("#dialog-form").dialog({
                autoOpen: false,
                width: 1024,
                modal: true,
                buttons: {
                    Cancel: function () {
                        $(this).dialog("close");
                    }
                }
            });
        }
        function showdialog() {
            $("#dialog-form").dialog("open")
        }
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <div class="row-fluid">
        <div class="span12">
            <div class="head">
                <div class="isw-grid">
                </div>
                <h1>
                    Searching</h1>
                <div class="clear">
                </div>
            </div>
            <div class="block-fluid" style="padding: 10px 0px 5px 10px">
                <table width="100%" cellspacing="0" cellpadding="0" class="">
                    <tbody>
                        <tr>
                            <td>
                                Short Code
                            </td>
                            <td>
                                <asp:DropDownList ID="ddlShortCode" runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Phone Number
                            </td>
                            <td>
                                <asp:TextBox ID="txtPhoneNumber" runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Sent time
                            </td>
                            <td>
                                <asp:TextBox ID="txtFromDate" runat="server" />
                                To
                                <asp:TextBox ID="txtToDate" runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Status
                            </td>
                            <td>
                                <asp:TextBox ID="txtStatus" runat="server" />
                            </td>
                        </tr>
                    </tbody>
                </table>
                <div style="text-align: center">
                    <asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click"
                        CssClass="btn" />
                </div>
            </div>
        </div>
    </div>
    <asp:UpdatePanel ID="udpn" runat="server">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
        </Triggers>
        <ContentTemplate>
            <div class="row-fluid">
                <div class="span12">
                    <div class="head">
                        <div class="isw-grid">
                        </div>
                        <h1>
                            Statistic</h1>
                        <div class="clear">
                        </div>
                    </div>
                    <div class="block-fluid table-sorting">
                        <div role="grid" class="dataTables_wrapper" id="tSortable_wrapper">
                            <div id="tSortable_length" class="dataTables_length">
                                <label>
                                    Show
                                    <asp:DropDownList ID="tSortable_length" size="1" aria-controls="tSortable" runat="server"
                                        OnSelectedIndexChanged="tSortable_length_SelectedIndexChanged" AutoPostBack="true">
                                        <asp:ListItem Value="5">5</asp:ListItem>
                                        <asp:ListItem Value="10">10</asp:ListItem>
                                        <asp:ListItem Value="25">25</asp:ListItem>
                                        <asp:ListItem Value="50" Selected="True">50</asp:ListItem>
                                        <asp:ListItem Value="100">100</asp:ListItem>
                                    </asp:DropDownList>
                                    entries</label>
                            </div>
                            <div>
                                <uc1:ucPaging ID="pagingtop" runat="server" />
                            </div>
                            <table cellspacing="0" cellpadding="0" class="table dataTable" aria-describedby="tSortable_info"
                                style="width: 100%;">
                                <thead>
                                    <tr>
                                        <th>
                                            No
                                        </th>
                                        <th style="width: 100px">
                                            Short Code
                                        </th>
                                        <th style="width: 120px">
                                            Phone Number
                                        </th>
                                        <th>
                                            Message
                                        </th>
                                        <th style="width: 180px">
                                            Received Time
                                        </th>
                                        <th style="width: 80px">
                                            Status
                                        </th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <asp:Repeater ID="rptStatistic" runat="server" OnItemCreated="rptStatistic_ItemCreated">
                                        <ItemTemplate>
                                            <tr id="itemRow" runat="server">
                                                <td align="center" style="width: 30px">
                                                    <%#(Container.ItemIndex +1) + (pagingtop.CurrentPage - 1) * pagingtop.PageSize %>
                                                </td>
                                                <td>
                                                    <%#Eval("ShortCode")%>
                                                </td>
                                                <td>
                                                    <a class="subs" href="#" onclick="javascript:GetMT(this); showdialog(); return false;">
                                                        <%#Eval("Subs")%>
                                                        <input type="hidden" value='<%#Eval("MoGuid")%>' />
                                                    </a>
                                                </td>
                                                <td>
                                                    <%#Eval("Message")%>
                                                </td>
                                                <td>
                                                    <%#Convert.ToDateTime(Eval("ReceivedTime")).ToString("MM/dd/yyyy HH:mm:ss")%>
                                                </td>
                                                <td>
                                                    <%#Eval("Status")%>
                                                </td>
                                            </tr>
                                        </ItemTemplate>
                                    </asp:Repeater>
                                </tbody>
                            </table>
                            <div class="dataTables_info" id="tSortable_info">
                                <asp:Literal ID="ltrInfo" runat="server" />
                            </div>
                            <div class="dataTables_paginate paging_full_numbers" id="tSortable_paginate">
                                <uc1:ucPaging ID="pagingbottom" runat="server" />
                            </div>
                        </div>
                        <div class="clear">
                        </div>
                    </div>
                </div>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    <div class="dr">
        <span></span>
    </div>
    <asp:UpdateProgress ID="udprogress" DisplayAfter="1" runat="server">
        <ProgressTemplate>
            <div class="ui-widget-overlay ui-front">
                <img src="images/loading.gif" alt="Loading..." style="position: fixed; top: 50%; left: 50%" />
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
    <div id="dialog-form" title="Mt Statistic">
        <table border="1" width="100%" cellpadding="2" cellspacing="2" style="border-collapse: collapse"
            id="tbMT">
            <thead style="background: #CCCCCC; height: 35px">
                <tr>
                    <th style="width: 30px">
                        No
                    </th>
                    <th style="width: 100px">
                        Short Code
                    </th>
                    <th style="width: 120px">
                        Phone Number
                    </th>
                    <th>
                        Message
                    </th>
                    <th style="width: 180px">
                        Sent Time
                    </th>
                    <th style="width: 80px">
                        Status
                    </th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
    </div>
    <input type="hidden" id="formId" value="SmsMoStatistics" />
</asp:Content>
